<template>
  <ex-dialog width="600px" class="ex-diolog" :title="title" :visible="visible" :close-on-click-modal="false"
    @closeDialog="handleClose">
    <div class="main" v-loading="loading">
      <span>{{info}}</span>
    </div>
    <div class="button_box">
      <el-button type="primary" :loading="AgreeLoading" @click="submitForm">确认开奖</el-button>
      <el-button @click="handleClose">取消</el-button>
    </div>
  </ex-dialog>
</template>
<script>
  import Loading from "@/components/Loading/index";
  // api
  import {
    jackpotAwardDrawHint,
    jackpotAwardDraw
  } from "@/api/consumeMiningManagement/onlineClockingActivity";

  export default {
    components: {
      Loading,
    },
    props: {
      visible: Boolean,
      id: String,
      awardAssetType: String
    },
    data() {
      return {
        labelWidth: '120px',
        inputWidth: '300px',
        title: '确认开奖',
        loading: false,
        disabled: false,
        AgreeLoading: false, //按钮loading
        info: '', //开奖信息
      };
    },
    computed: {},
    created() {
      this.getDetail()
    },
    methods: {
      //取消
      handleClose(formName) {
        this.$emit("update:visible", false);
      },
      getDetail() {
        this.loading = true
        jackpotAwardDrawHint(this.id).then((res) => {
          this.info = res.result
          setTimeout(() => {
            this.loading = false;
          }, 300);
        }).catch(() => {
          this.loading = false;
        });
      },
      submitForm() {//创建确定
        this.AgreeLoading = true
        jackpotAwardDraw(this.id).then((res) => {
            this.$message({
              message: "操作成功",
              type: "success",
            });
            setTimeout(() => {
              this.$emit('success')
              this.handleClose()
              this.AgreeLoading = false
            }, 1000);
          })
          .catch(() => {
            this.AgreeLoading = false;
          });
      },
    },
  };

</script>
<style lang="scss" scoped>
  .ex-diolog {
    ::v-deep .ex--dialog--footer {
      border: none !important;
      padding: 0 !important;
    }

    ::v-deep .ex--dialog--main {
      padding: 10px 20px !important;
    }
  }

  .main {
    padding: 20px 20px;
  }

  .button_box {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px 0;
  }

</style>
